-
Notifications
You must be signed in to change notification settings - Fork 13.3k
syntax: Extra diagnostics for _
used in an identifier position
#32506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
let mut err = self.fatal(&format!("expected identifier, found `{}`", | ||
self.this_token_to_string())); | ||
if self.token == token::Underscore { | ||
err.fileline_note(self.span, "`_` is not an identifier but a wildcard pattern \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the reference, a "wildcard pattern" is ..
(two dots) which can match with multiple data fields, as in
struct S(i32, i32);
let S(..) = S(0, 1);
The underscore seems to be called a "placeholder".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, the compiler uses "wildcard", wikipedia uses it too and that part of the reference looks ancient and not well-maintained.
👍 while the referenced issue is a bit artificial, people are regularly confused by |
r? @Manishearth |
let mut err = self.fatal(&format!("expected identifier, found `{}`", | ||
self.this_token_to_string())); | ||
if self.token == token::Underscore { | ||
err.fileline_note(self.span, "`_` is a wildcard pattern and not an identifier"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "pattern, not an" instead of "pattern and not an"
@bors delegate+ r=me once you fix the nit. (comment |
📌 Commit 1c08cb1 has been approved by `Manishearth`` |
✌️ @petrochenkov can now approve this pull request |
@bors r- ugh, it picked up the r=manishearth from my comment |
@bors r=Manishearth |
📌 Commit 1cbdf4e has been approved by |
syntax: Extra diagnostics for `_` used in an identifier position Closes #32501
Closes #32501